import java.util.ArrayList;
import java.util.List;

/**
 * @author LKQ
 * @date 2022/2/16 14:21
 * @description 计数数组
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {4,3,2,7,8,2,3,1};
        solution.findDisappearedNumbers(nums);
    }
    public List<Integer> findDisappearedNumbers(int[] nums) {
        int n = nums.length;
        int[] ans = new int[n + 1];
        for (int num : nums) {
            ans[num] += num;
        }
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i <=n ; i++) {
            if (ans[i] == 0) {
                // 没有加过
                list.add(i);
            }
        }
        return list;
    }
}
